<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>OpenShoe: spi.h File Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenShoe
   &#160;<span id="projectnumber">0.1</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Defines</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">spi.h File Reference</div>  </div>
</div>
<div class="contents">

<p>SPI driver for AVR32 UC3.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;<a class="el" href="compiler_8h_source.html">compiler.h</a>&quot;</code><br/>
</div>
<p><a href="spi_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structspi__options__t.html">spi_options_t</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Option structure for SPI channels.  <a href="structspi__options__t.html#details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a0131f2774f4e3dd71567400683b60405">SPI_TIMEOUT</a>&#160;&#160;&#160;15000</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Time-out value (number of attempts).  <a href="#a0131f2774f4e3dd71567400683b60405"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a1ec07ad94d5f6276c1c0b41d0550fe52">SPI_MODE_0</a>&#160;&#160;&#160;0</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Spi Mode 0.  <a href="#a1ec07ad94d5f6276c1c0b41d0550fe52"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#af2af9f45539491c9753960535dc20fde">SPI_MODE_1</a>&#160;&#160;&#160;1</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Spi Mode 1.  <a href="#af2af9f45539491c9753960535dc20fde"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a> { <br/>
&#160;&#160;<a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982a826883012efb59b29ee363729ea51bc1">SPI_ERROR</a> =  -1, 
<a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982a2b1fe832bba9b2799c09ddec72f7df75">SPI_OK</a> =  0, 
<a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982aae8d126a5cc88871e124cb6de9d13c20">SPI_ERROR_TIMEOUT</a> =  1, 
<a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982a328f03299bad929fb56b83f9053aef74">SPI_ERROR_ARGUMENT</a>, 
<br/>
&#160;&#160;<a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982a01283f9df4cdf6697d23cdb09c4890e8">SPI_ERROR_OVERRUN</a>, 
<a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982a185a888047ea2c585fe7472c752723cf">SPI_ERROR_MODE_FAULT</a>, 
<a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982a52c5c585a979c4c81d104e7a75b04a1d">SPI_ERROR_OVERRUN_AND_MODE_FAULT</a>
<br/>
 }</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Status codes used by the SPI driver.  <a href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#ac247e771a2e97136b05dd5bfb4cd85f4">spi_initSlave</a> (volatile avr32_spi_t *spi, uint8_t bits, uint8_t spi_mode)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes the SPI in slave mode.  <a href="#ac247e771a2e97136b05dd5bfb4cd85f4"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a04a1d45030965c52dc63b205166c61c1">spi_initTest</a> (volatile avr32_spi_t *spi)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets up the SPI in a test mode where the transmitter is connected to the receiver (local loopback).  <a href="#a04a1d45030965c52dc63b205166c61c1"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a93b09f2d5b41fe71291968cd2658cba2">spi_initMaster</a> (volatile avr32_spi_t *spi, const <a class="el" href="structspi__options__t.html">spi_options_t</a> *options)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes the SPI in master mode.  <a href="#a93b09f2d5b41fe71291968cd2658cba2"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#ac4f834a88c24447093521628ed16a72b">getBaudDiv</a> (const unsigned int baudrate, uint32_t pba_hz)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Calculates the baudrate divider.  <a href="#ac4f834a88c24447093521628ed16a72b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#ac021c6142b0b063c5971eb450a78f061">spi_selectionMode</a> (volatile avr32_spi_t *spi, uint8_t variable_ps, uint8_t pcs_decode, uint8_t delay)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets up how and when the slave chips are selected (master mode only).  <a href="#ac021c6142b0b063c5971eb450a78f061"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#af9d47e62b6b92aa3d786229c24584ae1">spi_selectChip</a> (volatile avr32_spi_t *spi, unsigned char chip)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Selects slave chip.  <a href="#af9d47e62b6b92aa3d786229c24584ae1"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a6c7f9eff8ca5319ae5b998255d925a6a">spi_unselectChip</a> (volatile avr32_spi_t *spi, unsigned char chip)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Unselects slave chip.  <a href="#a6c7f9eff8ca5319ae5b998255d925a6a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a5487ca1d63a13d055c803a6c96067a6f">spi_setupChipReg</a> (volatile avr32_spi_t *spi, const <a class="el" href="structspi__options__t.html">spi_options_t</a> *options, uint32_t pba_hz)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets options for a specific slave chip.  <a href="#a5487ca1d63a13d055c803a6c96067a6f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#ac93e5990e8abc811f4ba2fb65e10e94d">spi_enable</a> (volatile avr32_spi_t *spi)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Enables the SPI.  <a href="#ac93e5990e8abc811f4ba2fb65e10e94d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a5cc4ac60e6ecf3cdc442265aaa0a63e0">spi_disable</a> (volatile avr32_spi_t *spi)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Disables the SPI.  <a href="#a5cc4ac60e6ecf3cdc442265aaa0a63e0"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#aa945d35a658c234e2cb650a53dcdaa37">spi_is_enabled</a> (volatile avr32_spi_t *spi)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Tests if the SPI is enabled.  <a href="#aa945d35a658c234e2cb650a53dcdaa37"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">unsigned char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a4e0840fa276e1e4bfe182769d458f9d6">spi_writeRegisterEmptyCheck</a> (volatile avr32_spi_t *spi)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks if there is no data in the transmit register.  <a href="#a4e0840fa276e1e4bfe182769d458f9d6"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#ab5b92c3f2168e3b0a28f6325efcad5f3">spi_write</a> (volatile avr32_spi_t *spi, uint16_t data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Writes one data word in master fixed peripheral select mode or in slave mode.  <a href="#ab5b92c3f2168e3b0a28f6325efcad5f3"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a7b54e1dd21fe488aeca4a28322df36ff">spi_variableSlaveWrite</a> (volatile avr32_spi_t *spi, uint16_t data, uint8_t pcs, uint8_t lastxfer)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Selects a slave in master variable peripheral select mode and writes one data word to it.  <a href="#a7b54e1dd21fe488aeca4a28322df36ff"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">unsigned char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a3675facf1bb501f769ce8e9a3c2fc23f">spi_writeEndCheck</a> (volatile avr32_spi_t *spi)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks if all transmissions are complete.  <a href="#a3675facf1bb501f769ce8e9a3c2fc23f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">unsigned char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a86f2b56ec7eeb0712ef0c5f43e9ae604">spi_readRegisterFullCheck</a> (volatile avr32_spi_t *spi)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks if there is data in the receive register.  <a href="#a86f2b56ec7eeb0712ef0c5f43e9ae604"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a532d7c45929be691f0c344bc53560676">spi_read</a> (volatile avr32_spi_t *spi, uint16_t *data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Reads one data word in master mode or in slave mode.  <a href="#a532d7c45929be691f0c344bc53560676"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">unsigned char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8h.html#a354beb51d8e5e95665c089832f3a8631">spi_getStatus</a> (volatile avr32_spi_t *spi)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets status information from the SPI.  <a href="#a354beb51d8e5e95665c089832f3a8631"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>SPI driver for AVR32 UC3. </p>
<p>This file defines a useful set of functions for the SPI interface on AVR32 devices.</p>
<ul>
<li>Compiler: IAR EWAVR32 and GNU GCC for AVR32</li>
<li>Supported devices: All AVR32 devices with an SPI module can be used.</li>
<li>AppNote:</li>
</ul>
<dl class="author"><dt><b>Author:</b></dt><dd>Atmel Corporation: <a href="http://www.atmel.com">http://www.atmel.com</a> <br/>
 Support and FAQ: <a href="http://support.atmel.no/">http://support.atmel.no/</a> </dd></dl>
</div><hr/><h2>Define Documentation</h2>
<a class="anchor" id="a1ec07ad94d5f6276c1c0b41d0550fe52"></a><!-- doxytag: member="spi.h::SPI_MODE_0" ref="a1ec07ad94d5f6276c1c0b41d0550fe52" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SPI_MODE_0&#160;&#160;&#160;0</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Spi Mode 0. </p>

</div>
</div>
<a class="anchor" id="af2af9f45539491c9753960535dc20fde"></a><!-- doxytag: member="spi.h::SPI_MODE_1" ref="af2af9f45539491c9753960535dc20fde" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SPI_MODE_1&#160;&#160;&#160;1</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Spi Mode 1. </p>

</div>
</div>
<a class="anchor" id="a0131f2774f4e3dd71567400683b60405"></a><!-- doxytag: member="spi.h::SPI_TIMEOUT" ref="a0131f2774f4e3dd71567400683b60405" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SPI_TIMEOUT&#160;&#160;&#160;15000</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Time-out value (number of attempts). </p>

</div>
</div>
<hr/><h2>Enumeration Type Documentation</h2>
<a class="anchor" id="a856ecadf3d7fe18c4fc3ae56500f8982"></a><!-- doxytag: member="spi.h::spi_status_t" ref="a856ecadf3d7fe18c4fc3ae56500f8982" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Status codes used by the SPI driver. </p>
<dl><dt><b>Enumerator: </b></dt><dd><table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><em><a class="anchor" id="a856ecadf3d7fe18c4fc3ae56500f8982a826883012efb59b29ee363729ea51bc1"></a><!-- doxytag: member="SPI_ERROR" ref="a856ecadf3d7fe18c4fc3ae56500f8982a826883012efb59b29ee363729ea51bc1" args="" -->SPI_ERROR</em>&nbsp;</td><td>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a856ecadf3d7fe18c4fc3ae56500f8982a2b1fe832bba9b2799c09ddec72f7df75"></a><!-- doxytag: member="SPI_OK" ref="a856ecadf3d7fe18c4fc3ae56500f8982a2b1fe832bba9b2799c09ddec72f7df75" args="" -->SPI_OK</em>&nbsp;</td><td>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a856ecadf3d7fe18c4fc3ae56500f8982aae8d126a5cc88871e124cb6de9d13c20"></a><!-- doxytag: member="SPI_ERROR_TIMEOUT" ref="a856ecadf3d7fe18c4fc3ae56500f8982aae8d126a5cc88871e124cb6de9d13c20" args="" -->SPI_ERROR_TIMEOUT</em>&nbsp;</td><td>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a856ecadf3d7fe18c4fc3ae56500f8982a328f03299bad929fb56b83f9053aef74"></a><!-- doxytag: member="SPI_ERROR_ARGUMENT" ref="a856ecadf3d7fe18c4fc3ae56500f8982a328f03299bad929fb56b83f9053aef74" args="" -->SPI_ERROR_ARGUMENT</em>&nbsp;</td><td>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a856ecadf3d7fe18c4fc3ae56500f8982a01283f9df4cdf6697d23cdb09c4890e8"></a><!-- doxytag: member="SPI_ERROR_OVERRUN" ref="a856ecadf3d7fe18c4fc3ae56500f8982a01283f9df4cdf6697d23cdb09c4890e8" args="" -->SPI_ERROR_OVERRUN</em>&nbsp;</td><td>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a856ecadf3d7fe18c4fc3ae56500f8982a185a888047ea2c585fe7472c752723cf"></a><!-- doxytag: member="SPI_ERROR_MODE_FAULT" ref="a856ecadf3d7fe18c4fc3ae56500f8982a185a888047ea2c585fe7472c752723cf" args="" -->SPI_ERROR_MODE_FAULT</em>&nbsp;</td><td>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a856ecadf3d7fe18c4fc3ae56500f8982a52c5c585a979c4c81d104e7a75b04a1d"></a><!-- doxytag: member="SPI_ERROR_OVERRUN_AND_MODE_FAULT" ref="a856ecadf3d7fe18c4fc3ae56500f8982a52c5c585a979c4c81d104e7a75b04a1d" args="" -->SPI_ERROR_OVERRUN_AND_MODE_FAULT</em>&nbsp;</td><td>
</td></tr>
</table>
</dd>
</dl>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="ac4f834a88c24447093521628ed16a72b"></a><!-- doxytag: member="spi.h::getBaudDiv" ref="ac4f834a88c24447093521628ed16a72b" args="(const unsigned int baudrate, uint32_t pba_hz)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int16_t getBaudDiv </td>
          <td>(</td>
          <td class="paramtype">const unsigned int&#160;</td>
          <td class="paramname"><em>baudrate</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>pba_hz</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Calculates the baudrate divider. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">baudrate</td><td>Baudrate value. </td></tr>
    <tr><td class="paramname">pba_hz</td><td>SPI module input clock frequency (PBA clock, Hz).</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Divider or error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">&gt;=0</td><td>Success. </td></tr>
    <tr><td class="paramname">&lt;0</td><td>Error. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a5cc4ac60e6ecf3cdc442265aaa0a63e0"></a><!-- doxytag: member="spi.h::spi_disable" ref="a5cc4ac60e6ecf3cdc442265aaa0a63e0" args="(volatile avr32_spi_t *spi)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void spi_disable </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Disables the SPI. </p>
<p>Ensures that nothing is transferred while setting up buffers.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance.</td></tr>
  </table>
  </dd>
</dl>
<dl class="warning"><dt><b>Warning:</b></dt><dd>This may cause data loss if used on a slave SPI. </dd></dl>

</div>
</div>
<a class="anchor" id="ac93e5990e8abc811f4ba2fb65e10e94d"></a><!-- doxytag: member="spi.h::spi_enable" ref="ac93e5990e8abc811f4ba2fb65e10e94d" args="(volatile avr32_spi_t *spi)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void spi_enable </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Enables the SPI. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a354beb51d8e5e95665c089832f3a8631"></a><!-- doxytag: member="spi.h::spi_getStatus" ref="a354beb51d8e5e95665c089832f3a8631" args="(volatile avr32_spi_t *spi)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned char spi_getStatus </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Gets status information from the SPI. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SPI_OK</td><td>Success. </td></tr>
    <tr><td class="paramname">SPI_ERROR_OVERRUN</td><td>Overrun error. </td></tr>
    <tr><td class="paramname">SPI_ERROR_MODE_FAULT</td><td>Mode fault (SPI addressed as slave while in master mode). </td></tr>
    <tr><td class="paramname">SPI_ERROR_OVERRUN_AND_MODE_FAULT</td><td>Overrun error and mode fault. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a93b09f2d5b41fe71291968cd2658cba2"></a><!-- doxytag: member="spi.h::spi_initMaster" ref="a93b09f2d5b41fe71291968cd2658cba2" args="(volatile avr32_spi_t *spi, const spi_options_t *options)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a> spi_initMaster </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structspi__options__t.html">spi_options_t</a> *&#160;</td>
          <td class="paramname"><em>options</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initializes the SPI in master mode. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance. </td></tr>
    <tr><td class="paramname">options</td><td>Pointer to a structure containing initialization options.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SPI_OK</td><td>Success. </td></tr>
    <tr><td class="paramname">SPI_ERROR_ARGUMENT</td><td>Invalid argument(s) passed. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ac247e771a2e97136b05dd5bfb4cd85f4"></a><!-- doxytag: member="spi.h::spi_initSlave" ref="ac247e771a2e97136b05dd5bfb4cd85f4" args="(volatile avr32_spi_t *spi, uint8_t bits, uint8_t spi_mode)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a> spi_initSlave </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>bits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>spi_mode</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initializes the SPI in slave mode. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance. </td></tr>
    <tr><td class="paramname">bits</td><td>Number of bits in each transmitted character (8 to 16). </td></tr>
    <tr><td class="paramname">spi_mode</td><td>Clock polarity and phase.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SPI_OK</td><td>Success. </td></tr>
    <tr><td class="paramname">SPI_ERROR_ARGUMENT</td><td>Invalid argument(s) passed. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a04a1d45030965c52dc63b205166c61c1"></a><!-- doxytag: member="spi.h::spi_initTest" ref="a04a1d45030965c52dc63b205166c61c1" args="(volatile avr32_spi_t *spi)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a> spi_initTest </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Sets up the SPI in a test mode where the transmitter is connected to the receiver (local loopback). </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SPI_OK</td><td>Success. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="aa945d35a658c234e2cb650a53dcdaa37"></a><!-- doxytag: member="spi.h::spi_is_enabled" ref="aa945d35a658c234e2cb650a53dcdaa37" args="(volatile avr32_spi_t *spi)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int spi_is_enabled </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Tests if the SPI is enabled. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd><code>1</code> if the SPI is enabled, otherwise <code>0</code>. </dd></dl>

</div>
</div>
<a class="anchor" id="a532d7c45929be691f0c344bc53560676"></a><!-- doxytag: member="spi.h::spi_read" ref="a532d7c45929be691f0c344bc53560676" args="(volatile avr32_spi_t *spi, uint16_t *data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a> spi_read </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Reads one data word in master mode or in slave mode. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance. </td></tr>
    <tr><td class="paramname">data</td><td>Pointer to the location where to store the received data word.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SPI_OK</td><td>Success. </td></tr>
    <tr><td class="paramname">SPI_ERROR_TIMEOUT</td><td>Time-out.</td></tr>
  </table>
  </dd>
</dl>
<dl class="note"><dt><b>Note:</b></dt><dd>Will block program execution until time-out occurs if no data is received or last transmission is not complete. Invoke <a class="el" href="spi_8h.html#a3675facf1bb501f769ce8e9a3c2fc23f">spi_writeEndCheck</a> or <a class="el" href="spi_8h.html#a86f2b56ec7eeb0712ef0c5f43e9ae604">spi_readRegisterFullCheck</a> beforehand if needed. </dd></dl>

</div>
</div>
<a class="anchor" id="a86f2b56ec7eeb0712ef0c5f43e9ae604"></a><!-- doxytag: member="spi.h::spi_readRegisterFullCheck" ref="a86f2b56ec7eeb0712ef0c5f43e9ae604" args="(volatile avr32_spi_t *spi)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned char spi_readRegisterFullCheck </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Checks if there is data in the receive register. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">1</td><td>Some data in RDR. </td></tr>
    <tr><td class="paramname">0</td><td>No data in RDR. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="af9d47e62b6b92aa3d786229c24584ae1"></a><!-- doxytag: member="spi.h::spi_selectChip" ref="af9d47e62b6b92aa3d786229c24584ae1" args="(volatile avr32_spi_t *spi, unsigned char chip)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a> spi_selectChip </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>chip</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Selects slave chip. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance. </td></tr>
    <tr><td class="paramname">chip</td><td>Slave chip number (normal: 0 to 3, extarnally decoded signal: 0 to 14).</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SPI_OK</td><td>Success. </td></tr>
    <tr><td class="paramname">SPI_ERROR_ARGUMENT</td><td>Invalid argument(s) passed. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ac021c6142b0b063c5971eb450a78f061"></a><!-- doxytag: member="spi.h::spi_selectionMode" ref="ac021c6142b0b063c5971eb450a78f061" args="(volatile avr32_spi_t *spi, uint8_t variable_ps, uint8_t pcs_decode, uint8_t delay)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a> spi_selectionMode </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>variable_ps</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>pcs_decode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>delay</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Sets up how and when the slave chips are selected (master mode only). </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance. </td></tr>
    <tr><td class="paramname">variable_ps</td><td>Target slave is selected in transfer register for every character to transmit. </td></tr>
    <tr><td class="paramname">pcs_decode</td><td>The four chip select lines are decoded externally. Values 0 to 14 can be given to <a class="el" href="spi_8h.html#af9d47e62b6b92aa3d786229c24584ae1">spi_selectChip</a>. </td></tr>
    <tr><td class="paramname">delay</td><td>Delay in PBA periods between chip selects.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SPI_OK</td><td>Success. </td></tr>
    <tr><td class="paramname">SPI_ERROR_ARGUMENT</td><td>Invalid argument(s) passed. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a5487ca1d63a13d055c803a6c96067a6f"></a><!-- doxytag: member="spi.h::spi_setupChipReg" ref="a5487ca1d63a13d055c803a6c96067a6f" args="(volatile avr32_spi_t *spi, const spi_options_t *options, uint32_t pba_hz)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a> spi_setupChipReg </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structspi__options__t.html">spi_options_t</a> *&#160;</td>
          <td class="paramname"><em>options</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>pba_hz</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Sets options for a specific slave chip. </p>
<p>The baudrate field has to be written before transfer in master mode. Four similar registers exist, one for each slave. When using encoded slave addressing, reg=0 sets options for slaves 0 to 3, reg=1 for slaves 4 to 7 and so on.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance. </td></tr>
    <tr><td class="paramname">options</td><td>Pointer to a structure containing initialization options for an SPI channel. </td></tr>
    <tr><td class="paramname">pba_hz</td><td>SPI module input clock frequency (PBA clock, Hz).</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SPI_OK</td><td>Success. </td></tr>
    <tr><td class="paramname">SPI_ERROR_ARGUMENT</td><td>Invalid argument(s) passed. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a6c7f9eff8ca5319ae5b998255d925a6a"></a><!-- doxytag: member="spi.h::spi_unselectChip" ref="a6c7f9eff8ca5319ae5b998255d925a6a" args="(volatile avr32_spi_t *spi, unsigned char chip)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a> spi_unselectChip </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>chip</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Unselects slave chip. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance. </td></tr>
    <tr><td class="paramname">chip</td><td>Slave chip number (normal: 0 to 3, extarnally decoded signal: 0 to 14).</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SPI_OK</td><td>Success. </td></tr>
    <tr><td class="paramname">SPI_ERROR_TIMEOUT</td><td>Time-out.</td></tr>
  </table>
  </dd>
</dl>
<dl class="note"><dt><b>Note:</b></dt><dd>Will block program execution until time-out occurs if last transmission is not complete. Invoke <a class="el" href="spi_8h.html#a3675facf1bb501f769ce8e9a3c2fc23f">spi_writeEndCheck</a> beforehand if needed. </dd></dl>

</div>
</div>
<a class="anchor" id="a7b54e1dd21fe488aeca4a28322df36ff"></a><!-- doxytag: member="spi.h::spi_variableSlaveWrite" ref="a7b54e1dd21fe488aeca4a28322df36ff" args="(volatile avr32_spi_t *spi, uint16_t data, uint8_t pcs, uint8_t lastxfer)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a> spi_variableSlaveWrite </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>pcs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>lastxfer</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Selects a slave in master variable peripheral select mode and writes one data word to it. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance. </td></tr>
    <tr><td class="paramname">data</td><td>The data word to write. </td></tr>
    <tr><td class="paramname">pcs</td><td>Slave selector (bit 0 -&gt; nCS line 0, bit 1 -&gt; nCS line 1, etc.). </td></tr>
    <tr><td class="paramname">lastxfer</td><td>Boolean indicating whether this is the last data word transfer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SPI_OK</td><td>Success. </td></tr>
    <tr><td class="paramname">SPI_ERROR_TIMEOUT</td><td>Time-out. </td></tr>
    <tr><td class="paramname">SPI_ERROR_ARGUMENT</td><td>Invalid argument(s) passed.</td></tr>
  </table>
  </dd>
</dl>
<dl class="note"><dt><b>Note:</b></dt><dd>Will block program execution until time-out occurs if transmitter is busy and transmit buffer is full. Invoke <a class="el" href="spi_8h.html#a4e0840fa276e1e4bfe182769d458f9d6">spi_writeRegisterEmptyCheck</a> beforehand if needed.</dd>
<dd>
Once the data has been written to the transmit buffer, the end of transmission is not waited for. Invoke <a class="el" href="spi_8h.html#a3675facf1bb501f769ce8e9a3c2fc23f">spi_writeEndCheck</a> if needed. </dd></dl>

</div>
</div>
<a class="anchor" id="ab5b92c3f2168e3b0a28f6325efcad5f3"></a><!-- doxytag: member="spi.h::spi_write" ref="ab5b92c3f2168e3b0a28f6325efcad5f3" args="(volatile avr32_spi_t *spi, uint16_t data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="spi_8h.html#a856ecadf3d7fe18c4fc3ae56500f8982">spi_status_t</a> spi_write </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Writes one data word in master fixed peripheral select mode or in slave mode. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance. </td></tr>
    <tr><td class="paramname">data</td><td>The data word to write.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SPI_OK</td><td>Success. </td></tr>
    <tr><td class="paramname">SPI_ERROR_TIMEOUT</td><td>Time-out.</td></tr>
  </table>
  </dd>
</dl>
<dl class="note"><dt><b>Note:</b></dt><dd>Will block program execution until time-out occurs if transmitter is busy and transmit buffer is full. Invoke <a class="el" href="spi_8h.html#a4e0840fa276e1e4bfe182769d458f9d6">spi_writeRegisterEmptyCheck</a> beforehand if needed.</dd>
<dd>
Once the data has been written to the transmit buffer, the end of transmission is not waited for. Invoke <a class="el" href="spi_8h.html#a3675facf1bb501f769ce8e9a3c2fc23f">spi_writeEndCheck</a> if needed. </dd></dl>

</div>
</div>
<a class="anchor" id="a3675facf1bb501f769ce8e9a3c2fc23f"></a><!-- doxytag: member="spi.h::spi_writeEndCheck" ref="a3675facf1bb501f769ce8e9a3c2fc23f" args="(volatile avr32_spi_t *spi)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned char spi_writeEndCheck </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Checks if all transmissions are complete. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">1</td><td>All transmissions complete. </td></tr>
    <tr><td class="paramname">0</td><td>Transmissions not complete. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a4e0840fa276e1e4bfe182769d458f9d6"></a><!-- doxytag: member="spi.h::spi_writeRegisterEmptyCheck" ref="a4e0840fa276e1e4bfe182769d458f9d6" args="(volatile avr32_spi_t *spi)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned char spi_writeRegisterEmptyCheck </td>
          <td>(</td>
          <td class="paramtype">volatile avr32_spi_t *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Checks if there is no data in the transmit register. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>Base address of the SPI instance.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">1</td><td>No data in TDR. </td></tr>
    <tr><td class="paramname">0</td><td>Some data in TDR. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Mon Dec 19 2011 21:04:53 for OpenShoe by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
